<{include file="header.html"}>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://www.google.com/jsapi?"></script>
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js"></script>

<style type="text/css">
.tooltip{
    visibility:hidden;
    background-color: #fff;
    border: 1px solid gray;
    font-size: 13px;
	font-family: Tahoma,Geneva,Kalimati,sans-serif;
    z-index: 10;  
    position: absolute;
    width: 180px;
}
.tooltip div{
    padding-left: 5px
}
</style>

<script type="text/javascript">
    var map;
	var geocoder;
	var botLeft = null;
	var topRight = null;
	var markersArray = [];

	//--------------------Google Map Api V3--------------------------//
	google.load("prototype", "1.6.1.0");

	// on page load complete, fire off a jQuery json-p query
	// against Google web search
	google.setOnLoadCallback(init);

	function init() {
        var myOptions = {
		  zoom: <{$smarty.const.CITY_ZOOM}>,
		  mapTypeId: google.maps.MapTypeId.ROADMAP,
          scaleControl:true,
		  disableAutoPan:true,
		  navigationControl:true,
		  mapTypeControl:true,
		  mapTypeControlOptions: {style:google.maps.MapTypeControlStyle.DROPDOWN_MENU}
		};
		geocoder = new google.maps.Geocoder();
		map = new google.maps.Map(document.getElementById("map"), myOptions);
        var center = getLatLangforCenter()
        <{if $country->ID}>
            <{if $city->CITY_STATUS}>
                setCity("1");
            <{else}>
                map.setCenter(center);
                createCenterMaker(center);
            <{/if}>
        <{else}>
            map.setCenter(center);
        <{/if}>
	}

	function createCenterMaker(position) {
		var marker = new google.maps.Marker({
			position: position,
			clickable: true,
            draggable:true,
			map: map,
			icon: 'http://www.celltreesinc.com/maps/icons/purple-dot.png'
		});
        markersArray.push(marker);
		google.maps.event.addListener(marker, 'click', function(e) {
			if (document.getElementById("lat")) {
                document.getElementById("lat").value = e.latLng.lat().toFixed(5);
            }
            if (document.getElementById("lon")) {
                document.getElementById("lon").value = e.latLng.lng().toFixed(5);
            }
	  	});

       google.maps.event.addListener(marker, 'mouseover', function(e) {
            geocoder.geocode({'latLng': e.latLng}, function(results, status) {
              if (status == google.maps.GeocoderStatus.OK) {
                if (results[1]) {
                    var address= (results[1].formatted_address);
                    showTooltip(address, e.latLng);
                }
              }
            });
		});
		google.maps.event.addListener(marker, 'mouseout', function() {
			if ( map.getDiv().children[1]) {
	        	 map.getDiv().children[1].remove();
	        }
		});
        
	}

	function getLatLangforCenter() {
		var lat = parseFloat('<{$smarty.const.CITY_CENTER_LATTITUDE}>');
		var lon = parseFloat('<{$smarty.const.CITY_CENTER_LANGTITUDE}>');
        <{if $city->ID && !$city->CITY_STATUS}>
            lat = parseFloat("<{$city->LAT}>");
            lon = parseFloat("<{$city->LON}>");
        <{/if}>
        return new google.maps.LatLng(lat, lon);
	}

    function setCity(_case) {
        if (markersArray) {
            var i = markersArray.length;
            while (markersArray.length) {
                i--;
                markersArray[i].setMap(null);
                markersArray.pop();
            }
        }
        if (_case == 2) {
            var agr = new Array();
            var id_city = document.getElementById('city'); 
            if (!id_city.value) {
                return;
            }
            agr.push(id_city.value);
            var result = callFunction('City::getLatLonById',agr, 'json');
            if(!result)
            {
                showErrorBubble(name, '<{$smarty.const._MSG_INVALID_CITY_NAME|utf8_escape_js}>');
                return false;
            }
            
            if (result.name) {
                var city = result.name;
                var code = "<{$country->CODE}>";
            } else {
                var lat = parseFloat(result.lat);
                var lon = parseFloat(result.lon);
                var latlon = new google.maps.LatLng(lat, lon);
                map.setCenter(latlon);
                createCenterMaker(latlon);
                return;
            }
        } else if (_case == 1) {
            var city = getI18nFormat("<{$city->NAME}>");
            var code = "<{$country->CODE}>";
        } else {
            var code = document.getElementById("code");
            var city = document.getElementById("city_name_en");
            
            if(isEmptyTextBox(code, '<{$smarty.const._MSG_COUNTRY_CODE_EMPTY|utf8_escape_js}>'))
            {
                return false;
            }

            var code_pattern  =  new RegExp("^\[A-Za-z]{2}$");
            if(!code.value.match(code_pattern)) {
                showErrorBubble(code, '<{$smarty.const._MSG_INVALID_COUNTRY_CODE|utf8_escape_js}>');
                return false;
            }
            
            var message = '<{$smarty.const._MSG_VALUE_NAME_BY_LANGUAE_INVALID|utf8_escape_js}>';
            message = message.replace("[LANGUAGE]", '&lt;en&gt;');
            if(isEmptyTextBox(city, message))
            {
                return false;
            }
            
            code = code.value;
            city = city.value;
        }

        var name_city = city;
        
        if (geocoder) {
		  geocoder.geocode( { 'address': name_city, 'region': code.toLowerCase()}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
                var count = results.length;
                if (count > 1) {
                    var max_x = <{$smarty.const.BOTTOM_RIGHT_LONG}>;
                    var min_x = <{$smarty.const.TOP_LEFT_LONG}>;
                    var max_y = <{$smarty.const.BOTTOM_RIGHT_LAT}>;
                    var min_y = <{$smarty.const.TOP_LEFT_LAT}>;
                    for(var i=0;i<count;i++){
                        lat   = results[i].geometry.location.lat();
                        lon  = results[i].geometry.location.lng();

                        if(max_x < lon){
                            max_x = parseFloat(lon);
                        }
                        if(min_x > lon){
                            min_x = parseFloat(lon);
                        }
                        if(max_y < lat){
                            max_y = parseFloat(lat);
                        }
                        if(min_y > lat){
                            min_y = parseFloat(lat);
                        }
                        var lat2 = parseFloat(lat);
                        var lon2 = parseFloat(lon);
                        var position = new google.maps.LatLng(lat2, lon2);
                        var marker = new google.maps.Marker({
                            position: position,
                            clickable: true,
                            draggable:true,
                            map: map,
                            icon: 'http://www.celltreesinc.com/maps/icons/purple-dot.png'
                        });
                        markersArray.push(marker);
                        google.maps.event.addListener(marker, 'click', function(e) {
                            if (document.getElementById("lat")) {
                                document.getElementById("lat").value = e.latLng.lat().toFixed(5);
                            }
                            if (document.getElementById("lon")) {
                                document.getElementById("lon").value = e.latLng.lng().toFixed(5);
                            }
                        });

                        google.maps.event.addListener(marker, 'mouseover', function(e) {
                            geocoder.geocode({'latLng': e.latLng}, function(results, status) {
                              if (status == google.maps.GeocoderStatus.OK) {
                                if (results[1]) {
                                    var address= (results[1].formatted_address);
                                    showTooltip(address, e.latLng);
                                }
                              }
                            });
                        });
                        google.maps.event.addListener(marker, 'mouseout', function() {
                            if ( map.getDiv().children[1]) {
                                 map.getDiv().children[1].remove();
                            }
                        });

                        google.maps.event.addListener(marker, "dragend", function(e) {
                            if (document.getElementById("lat")) {
                                document.getElementById("lat").value = e.latLng.lat().toFixed(5);
                            }
                            if (document.getElementById("lon")) {
                                document.getElementById("lon").value = e.latLng.lng().toFixed(5);
                            }
                        });
                    }
                    if(max_x!=null && max_y!=null){
                        botLeft = new google.maps.LatLng(min_y,min_x);
                        topRight = new google.maps.LatLng(max_y,max_x);
                        lat = parseFloat((min_y+max_y)/2);
                        lon = parseFloat((min_x+max_x)/2);
                    }
                    var center = new google.maps.LatLng(lat, lon);
                    map.setCenter(center);
                    if(botLeft != null && topRight!=null){
                        var bounds = new google.maps.LatLngBounds(botLeft, topRight);
                        map.fitBounds(bounds);
                    }
                 } else {
                    lat   = results[0].geometry.location.lat();
                    lon  = results[0].geometry.location.lng();
                    var center = new google.maps.LatLng(lat, lon);
                    map.setCenter(center);
                    map.setZoom(<{$smarty.const.CITY_ZOOM}>);
                    createCenterMaker(center);
                    document.getElementById("lat").value = lat.toFixed(5);
                    document.getElementById("lon").value = lon.toFixed(5);
                }
            } else {
				showErrorBubble(document.getElementById('city_name_en'), '<{$smarty.const._MSG_INVALID_CITY|utf8_escape_js}>');
			}
		  });
		}
		return true;
	}
    
    /*********************Tooltip**********************/
	function getCanvasXY(caurrentLatLng){
    	var scale = Math.pow(2, map.getZoom());
     	var nw = new google.maps.LatLng(
        	map.getBounds().getNorthEast().lat(),
        	map.getBounds().getSouthWest().lng()
     	);
     	var worldCoordinateNW = map.getProjection().fromLatLngToPoint(nw);
     	var worldCoordinate = map.getProjection().fromLatLngToPoint(caurrentLatLng);
     	var caurrentLatLngOffset = new google.maps.Point(
        	Math.floor((worldCoordinate.x - worldCoordinateNW.x) * scale),
         	Math.floor((worldCoordinate.y - worldCoordinateNW.y) * scale)
     	);
     	return caurrentLatLngOffset;
  	}

  	function showTooltip(html, caurrentLatLng) {
    	var projection;
        var tooltipDiv;
        projection = map.getProjection() ;
        if (map.getDiv().children[1]) {
        	map.getDiv().children[1].remove();
        }
        tooltipDiv = document.createElement("div");
        tooltipDiv.className  = 'tooltip';
        tooltipDiv.innerHTML = html;

        map.getDiv().appendChild(tooltipDiv);
                
        var mapWidth = map.getDiv().getWidth();
    	var mapHeight = map.getDiv().getHeight();
    	
    	var divWidth = tooltipDiv.getWidth();
	    var divHeight = tooltipDiv.getHeight();
	    var clickedPosition = getCanvasXY(caurrentLatLng);
	    var x = clickedPosition.x;
	    var y = clickedPosition.y ;
	
	    if((mapWidth - x ) < divWidth) {
			x = x - divWidth;
	    }
	    if((mapHeight - y ) < divHeight) {
	        y = y - 1.5*divHeight;
	    }
	    tooltipDiv.style.top = y+'px';
	    tooltipDiv.style.left = x+'px';
	    tooltipDiv.style.visibility = "visible";
	}
    
    function getI18nFormat(str_value)
    {
        var language_code = "<{$smarty.const.DEFAULT_LANGUAGE}>";
        var pattern = '<'+language_code.toLowerCase()+'>(.*?)</'+language_code.toLowerCase()+'>';
        var re = new RegExp(pattern);
        var data = re.exec(str_value);
        if(data != null)
        {
            return data[1];
        }
        var pattern = '<([a-z]{2}(_[A-Z]{2})*?)>(.*?)</([a-z]{2}(_[A-Z]{2})*?)>';
        var re = new RegExp(pattern);
        var data = re.exec(str_value);
        if(data != null)
        {
            if (data.length == 4) {
            return data[2];
            } else if (data.length == 6) {
                return data[3];
            } 
        }
        
        return str_value;
    }
    var country_lang_arr = [];
    var city_lang_arr = [];
    var tc_lang_arr = [];
    var first_element = '<{$smarty.const._LB_CHOOSE|utf8_escape_html}>';
    var err = '<{$smarty.const._MSG_COUNTRY_LANGUAGE_CODE_INVALID|utf8_escape_js}>';
    var err_1 = '<{$smarty.const._MSG_VALUE_NAME_BY_LANGUAE_INVALID|utf8_escape_js}>';
    var err_2 = '<{$smarty.const._MSG_VALUE_NAME_BY_LANGUAGE_EXISTS|utf8_escape_js}>';
    
	function validate()
	{
		var id = document.getElementById('ID');
		var code = document.getElementById('code');
		var city = document.getElementById('city');
		var lat = document.getElementById('lat');
		var lon = document.getElementById('lon');
		var language = document.getElementById('language_code');
		var term_condition = document.getElementById('term_condition');
	    
        var agr = new Array();
        agr.push(id.value);
        if (!validateLang('country', 'Country::isExistsByName', agr)) {
            return false;
        }
        
        if(isEmptyTextBox(code, '<{$smarty.const._MSG_COUNTRY_CODE_EMPTY|utf8_escape_js}>'))
		{
			return false;
		}

		var code_pattern  =  new RegExp("^\[A-Za-z]{2}$");
		
		if(!code.value.match(code_pattern)) {
			showErrorBubble(code, '<{$smarty.const._MSG_INVALID_COUNTRY_CODE|utf8_escape_js}>');
			return false;
		}
        
		var agr = new Array();
		agr.push(trim(code.value));
		agr.push(id.value);
		if(callFunction('Country::isExistsByCode',agr) )
		{
			showErrorBubble(code, '<{$smarty.const._MSG_COUNTRY_CODE_EXISTS|utf8_escape_js}>');
			return false;
		}
        
		<{if !$country->ID}>
        var agr = new Array();
        agr.push(0);
        agr.push(0);
        if (!validateLang('city', 'City::isExistsByName', agr)) {
            return false;
        }
        
        if (lat.value.length == 0)
		{
            showErrorBubble(lat, '<{$smarty.const._MSG_LAT_NOT_EMPTY|utf8_escape_js}>');
			return false;
		}
        if (lat.value.length == 0 || isNaN(lat.value) || lat.value < <{$smarty.const.MIN_LATITUDE}> || lat.value > <{$smarty.const.MAX_LATITUDE}>) {
			showErrorBubble(lat, '<{$smarty.const._MSG_CITY_LAT_INVALID_NUMBER|utf8_escape_js}>');
			return false;
		}
        if (lon.value.length == 0)
		{
            showErrorBubble(lon, '<{$smarty.const._MSG_LON_NOT_EMPTY|utf8_escape_js}>');
			return false;
		}
		if (lon.value.length == 0 || isNaN(lon.value) || lon.value < <{$smarty.const.MIN_LONGITUDE}> || lon.value > <{$smarty.const.MAX_LONGITUDE}>) {
			showErrorBubble(lon, '<{$smarty.const._MSG_CITY_LON_INVALID_NUMBER|utf8_escape_js}>');
			return false;
		}       
        <{else}>
        if(city.value=="")
		{
            showErrorBubble(city, '<{$smarty.const._MSG_INVALID_COUNTRY_CITY_CHOOSE|utf8_escape_js}>');
			return false;
		}           
		<{/if}>
		if(isEmptyTextBox(language, '<{$smarty.const._MSG_INVALID_COUNTRY_LANGUAGE_CODE_NOT_EMPTY|utf8_escape_js}>'))
		{
			return false;
		}
		if(!/^[a-z]{2}(_[A-Z]{2})*?$/.test(language.value))
		{
    		showErrorBubble(language, '<{$smarty.const._MSG_COUNTRY_LANGUAGE_CODE_INVALID|utf8_escape_js}>');
			return false;
		}
        if(document.getElementById('tc_name_'+language.value).disabled == true) {
            showErrorBubble(document.getElementById('tc_language'), '<{$smarty.const._MSG_COUNTRY_TERM_CONDITION_MISSING_LANG|utf8_escape_js}> '+ '&lt;'+language.value+'&gt;');
			return false;
		}
        
        if (!validateLang('tc', '')) {
            return false;
        }
		
		document.country.submit();
	}
    
    function addTCLang(element, lang_arr, code) {
        document.getElementById('tc_label').style.display= '';
        addLang(element, lang_arr, code);
    }
    
    function deleteTCLang(element, code, lang_arr, tc_language) {
        deleteLang(element, code, lang_arr);
        if (tc_lang_arr.length == 0) {
            document.getElementById('tc_label').style.display= 'none';
        }
    }
    <{foreach from=$country_name_arr key=code item=name}>
        country_lang_arr.push('<{$code}>');
    <{/foreach}>
    
    <{foreach from=$tc_arr key=code item=name}>
        tc_lang_arr.push('<{$code}>');
    <{/foreach}>
    
    <{if !$country->ID}>
    <{foreach from=$city_name_arr key=code item=name}>
        city_lang_arr.push('<{$code}>');
    <{/foreach}>
    <{/if}>
</script>

	<div class="one_center">
		<div class="box_two_third">
			<div class="box_head"><{$smarty.const._LB_COUNTRY|utf8_escape_html}></div>
			<div class="box_content" >
				<form action="" name="country" method="post">
				<input type="hidden" id="ID" name="ID" value="<{$country->ID}>"/>
				<input type="hidden" id="act" name="act" value="<{$smarty.const.ACT_VALID_EDIT}>"/>
				<table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td>
                            <div style="min-height: 400px">
                                <table>
                                    <tr>
                                        <td width="20%"><{$smarty.const._LB_COUNTRY|utf8_escape_html}>&nbsp;<{$smarty.const._LB_LANGUAGE|utf8_escape_html}>&nbsp;:&nbsp;</td>
                                        <td col>
                                            <select id="country_language" name="country_language" style="width: 180px;">
                                                <option value=""><{$smarty.const._LB_CHOOSE|utf8_escape_html}></option>
                                                <{foreach from=$front_language item=name key=code}>
                                                   <{if $code != 'en' && !$country_name_arr.$code}>
                                                   <option value="<{$code|utf8_escape_html}>"><{$name|utf8_escape_html}>&nbsp;(<{$code|utf8_escape_html}>)</option>'
                                                   <{/if}>
                                                   <script type="text/javascript">
                                                      front_language_arr.push(new Front_Language("<{$code|utf8_escape_html}>", "<{$name|utf8_escape_html}>"));
                                                   </script>
                                                <{/foreach}>
                                            </select>&nbsp;
                                            <a id="add_more_country_lang" onclick="addLang('country', country_lang_arr, 'en')" href="#country_language">
                                                <img src="<{$smarty.const.APPLICATION_URL}>/images/<{$smarty.const.IMAGE_NAME_MORE}>" title="<{$smarty.const._LB_ADD_MORE|utf8_escape_html}>" alt="<{$smarty.const._LB_ADD_MORE|utf8_escape_html}>"/>
                                            </a>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="15%" valign="top" ><label for="name"><{$smarty.const._LB_COUNTRY_NAME|utf8_escape_html}>&nbsp;:&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}></label></td>
                                        <td>
                                            <div>
                                               <table>
                                                   <{foreach from=$front_language item=name key=code name=name_index}>
                                                        <tr id="country_div_<{$code}>" <{if $code != 'en' && !$country_name_arr.$code}>style="display:none"<{/if}>>
                                                            <td width="10px" id="country_lbl_<{$code|utf8_escape_html}>"><{$name|utf8_escape_html}>&nbsp;(<{$code|utf8_escape_html}>)</td>
                                                            <td><input <{if $code != 'en' && !$country_name_arr.$code}>disabled="true"<{/if}> name="country_name[<{$code|utf8_escape_html}>]" id="country_name_<{$code|utf8_escape_html}>" type="text" size="<{$smarty.const.SIZE_NAME}>" value="<{$country_name_arr.$code}>"/>
                                                            <{if $code != 'en'}>
                                                            <a onclick="deleteLang('country', '<{$code|utf8_escape_html}>', country_lang_arr, 'en')" href="#country_language">
                                                                <img src="<{$smarty.const.APPLICATION_URL}>/images/<{$smarty.const.IMAGE_NAME_MINUS_SMALL}>" title="<{$smarty.const._LB_REMOVE|utf8_escape_html}>" alt="<{$smarty.const._LB_REMOVE|utf8_escape_html}>"/>
                                                            </a>
                                                            <{/if}>
                                                            <td>
                                                        </tr>
                                                    <{/foreach}>
                                                </table> 
                                            </div>
                                        </td>
                                        
                                    </tr>
                                    <tr>
                                        <td><label for="code"><{$smarty.const._LB_COUNTRY_CODE|utf8_escape_html}>&nbsp;:&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}></label></td>
                                        <td><input name="code" id="code" type="text" size="<{$smarty.const.SIZE_NAME}>" value="<{$country->CODE|utf8_escape_html}>" maxlength="2" style="margin-top:5px" /></td>
                                    </tr>
                                    <{if $country->ID}>
                                    <tr>
                                        <td><label for="city"><{$smarty.const._LB_MAIN_CITY|utf8_escape_html}>&nbsp;:&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}></label></td>
                                        <td>
                                            <select id="city" name="city" style="width: 180px;" onchange="setCity(2);">
                                                <option value=""><{$smarty.const._LB_SELECT|utf8_escape_html}></option>
                                                <{while $cities->fetch()}>
                                                    <option value="<{$cities->ID}>" <{if $country->ID_CITY == $cities->ID}>selected<{/if}>><{$cities->NAME|i18n|utf8_escape_html}></option>
                                                <{/while}>
                                            </select>
                                       </td>
                                    </tr>
                                    <{else}>
                                    <tr>
                                        <td width="20%" valign="top"><{$smarty.const._LB_CITY|utf8_escape_html}>&nbsp;<{$smarty.const._LB_LANGUAGE|utf8_escape_html}>&nbsp;:&nbsp;</td>
                                        <td col>
                                            <select id="city_language" name="city_language" style="width: 180px;">
                                                <option value=""><{$smarty.const._LB_CHOOSE|utf8_escape_html}></option>
                                                <{foreach from=$front_language item=name key=code}>
                                                   <{if $code != 'en' && !$city_name_arr.$code}>
                                                   <option value="<{$code|utf8_escape_html}>"><{$name|utf8_escape_html}>&nbsp;(<{$code|utf8_escape_html}>)</option>'
                                                   <{/if}>
                                                <{/foreach}>
                                            </select>&nbsp;
                                            <a id="add_more_city_lang" onclick="addLang('city', city_lang_arr, 'en')" href="#city_language">
                                                <img src="<{$smarty.const.APPLICATION_URL}>/images/<{$smarty.const.IMAGE_NAME_MORE}>" title="<{$smarty.const._LB_ADD_MORE|utf8_escape_html}>" alt="<{$smarty.const._LB_ADD_MORE|utf8_escape_html}>"/>
                                            </a>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td><label for="city"><{$smarty.const._LB_MAIN_CITY_NAME|utf8_escape_html}>&nbsp;:&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}></label></td>
                                        <td>
                                            <div>
                                               <table>
                                                   <{foreach from=$front_language item=name key=code name=name_index}>
                                                        <tr id="city_div_<{$code}>" <{if $code != 'en' && !$city_name_arr.$code}>style="display:none"<{/if}>>
                                                            <td width="10px" id="city_lbl_<{$code|utf8_escape_html}>"><{$name|utf8_escape_html}>&nbsp;(<{$code|utf8_escape_html}>)</td>
                                                            <td><input <{if $code != 'en' && !$city_name_arr.$code}>disabled="true"<{/if}> name="city_name[<{$code|utf8_escape_html}>]" id="city_name_<{$code|utf8_escape_html}>" type="text" size="<{$smarty.const.SIZE_NAME}>" value="<{$city_name_arr.$code}>"/>
                                                            <{if $code != 'en'}>
                                                            <a onclick="deleteLang('city', '<{$code|utf8_escape_html}>', city_lang_arr, 'en')" href="#">
                                                                <img src="<{$smarty.const.APPLICATION_URL}>/images/<{$smarty.const.IMAGE_NAME_MINUS_SMALL}>" title="<{$smarty.const._LB_REMOVE|utf8_escape_html}>" alt="<{$smarty.const._LB_REMOVE|utf8_escape_html}>"/>
                                                            </a>
                                                            <{else}>
                                                                <a href="#city_language" onclick="javascript:setCity('')">
                                                                    <img title="<{$smarty.const._MSG_GO_TO_MAP}>"  src="<{$smarty.const.APPLICATION_URL}>/images/<{$smarty.const.IMAGE_GOOGLE_MAP}>" class="small"/>
                                                                </a>
                                                            <{/if}>
                                                            <td>
                                                        </tr>
                                                    <{/foreach}>
                                                </table> 
                                            </div>
                                       </td>
                                    </tr>
                                    <tr>
                                        <td><label for="lat"><{$smarty.const._LB_COUNTRY_LAT|utf8_escape_html}>&nbsp;:&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}></label></td>
                                        <td><input name="lat" id="lat" type="text" size="<{$smarty.const.SIZE_NAME}>" value="<{$city->LAT|utf8_escape_html}>" style="margin-top:5px" <{if $country->ID}>disabled<{/if}> /></td>
                                    </tr>
                                    <tr>
                                        <td><label for="lon"><{$smarty.const._LB_COUNTRY_LON|utf8_escape_html}>&nbsp;:&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}></label></td>
                                        <td><input name="lon" id="lon" type="text" size="<{$smarty.const.SIZE_NAME}>" value="<{$city->LON|utf8_escape_html}>" style="margin-top:5px" <{if $country->ID}>disabled<{/if}> /></td>
                                    </tr>
                                    <{/if}>
                                    <tr>
                                        <td><label for="language_code"><{$smarty.const._LB_COUNTRY_LANGUAGE_CODE|utf8_escape_html}>&nbsp;:&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}></label></td>
                                        <td>
                                            <select id="language_code" name="language_code" style="width: 180px;">
                                                <option value=""><{$smarty.const._LB_CHOOSE|utf8_escape_html}></option>
                                                <{foreach from=$front_language item=name key=code}>
                                                   <option value="<{$code|utf8_escape_html}>" <{if $country->LANGUAGE_CODE == $code}>selected<{/if}>><{$name|utf8_escape_html}>&nbsp;(<{$code|utf8_escape_html}>)</option>'
                                                <{/foreach}>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="20%"><{$smarty.const._LB_LANGUAGE|utf8_escape_html}>&nbsp;:&nbsp;</td>
                                        <td col>
                                            <select id="tc_language" name="tc_language" style="width: 180px;">
                                                <option value=""><{$smarty.const._LB_CHOOSE|utf8_escape_html}></option>
                                                <{foreach from=$front_language item=name key=code}>
                                                   <{if !$tc_arr.$code}>
                                                   <option value="<{$code|utf8_escape_html}>"><{$name|utf8_escape_html}>&nbsp;(<{$code|utf8_escape_html}>)</option>'
                                                   <{/if}>
                                                <{/foreach}>
                                            </select>&nbsp;
                                            <a id="add_more_tc_lang" onclick="addTCLang('tc', tc_lang_arr, '')" href="#tc_language">
                                                <img src="<{$smarty.const.APPLICATION_URL}>/images/<{$smarty.const.IMAGE_NAME_MORE}>" title="<{$smarty.const._LB_ADD_MORE|utf8_escape_html}>" alt="<{$smarty.const._LB_ADD_MORE|utf8_escape_html}>"/>
                                            </a>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td id="tc_label" <{if $tc_arr|@count == 0 && $code != $country->LANGUAGE_CODE}>style="display:none"<{/if}> valign="top"><label for="term_condition"><{$smarty.const._LB_COUNTRY_TERM_CONDITION|utf8_escape_html}>&nbsp;:&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}></label></td>
                                        <td>
                                            <div>
                                               <table>
                                                   <{foreach from=$front_language item=name key=code name=name_index}>
                                                        <tr id="tc_div_<{$code}>" <{if $code != $country->LANGUAGE_CODE && !$tc_arr.$code}>style="display:none"<{/if}>>
                                                            <td width="10px" id="tc_lbl_<{$code|utf8_escape_html}>"><{$name|utf8_escape_html}>&nbsp;(<{$code|utf8_escape_html}>)</td>
                                                            <td style="vertical-align:middle;">
                                                                <textarea cols="37" rows="10" style="margin-top:5px" <{if $code != $country->LANGUAGE_CODE && !$tc_arr.$code}>disabled="true"<{/if}> name="term_condition[<{$code|utf8_escape_html}>]" id="tc_name_<{$code|utf8_escape_html}>"><{$tc_arr.$code|utf8_escape_textarea}></textarea>
                                                            <a onclick="deleteTCLang('tc', '<{$code|utf8_escape_html}>', tc_lang_arr, 'tc_language')" href="#tc_language">
                                                                <img src="<{$smarty.const.APPLICATION_URL}>/images/<{$smarty.const.IMAGE_NAME_MINUS_SMALL}>" title="<{$smarty.const._LB_REMOVE|utf8_escape_html}>" alt="<{$smarty.const._LB_REMOVE|utf8_escape_html}>"/>
                                                            </a>
                                                            <td>
                                                        </tr>
                                                    <{/foreach}>
                                                </table> 
                                            </div>          
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                        <td width="45%" rowspan ="20" valign="top" style="margin-right: 10px;padding-right: 10px;">
                            <div id ="map" style="width: 100%;height: 300px"></div>
                        </td>
                    </tr>
                    <tr>
                        <td class="submit" colspan="2" style="padding-top: 10px;">
                              <a id="auto_country_return" class="tribullet" id="btnReturn" href="<{$backlink}>"><{$smarty.const._LB_BACK}></a>
                              <a id="auto_country_validate" class="tribullet" href="#" onclick="validate()"><{$smarty.const._LB_VALIDATE}></a>
                        </td>
                    </tr>
				</table>
				</form>
			</div>
		</div>
	</div>

<{include file="footer.html"}>
